package com.lcredu.ajax.service;

import com.google.gson.Gson;
import com.lcredu.ajax.dao.UserDao;
import com.lcredu.ajax.entity.User;

/**
 * @author 黎长容
 * @date 2025-07-03 19:59
 */
public class UserService {
    //调用dao获取对象转为json对象
    public String getUserJson(String name) {
        UserDao userDao = new UserDao();
        User user = userDao.getUserByName(name);
        if (name.equals(user.getName())) {
            Gson gson = new Gson();
            String userJson = gson.toJson(user);
            return userJson;
        }else {
            return " ";
        }

        
    }
}
